<?php
session_start();
require_once "includes/pagination.php";
require_once "includes/config.php";
          require_once "includes/functions.php";

if(!empty($_REQUEST['editSellingProduct']))
{
$productId=$_REQUEST['editSellingProduct'];
$ownerId= $_SESSION['user_id_sess'];
$userId= $_SESSION['user_id_sess'];
$itemPerPage=10;
$sql="SELECT * FROM tbl_product WHERE product_id='$productId'";
	$rst=mysql_query($sql);
	if($rst) { $productInfo=mysql_fetch_array($rst);}
//$productInfo=getProductById($productId);
}
else
  echo "<script type='text/javascript'> window.location='index.php?notFound'; </script>";
  
 $pstr="";
$pstr.="<div id='panel' style='width:100%;'>
<table width='100%' border='0'>
<tr>
    <td ><strong style='color:#FDAD21; font-size:14px; float:left; margin:-10px 0px 0px 0px;'>Sellers selling your product</strong></td>
  </tr>
  <tr>
  <td height='27'><strong>".$productInfo['product_name']."</strong></td>
  </tr>
   <tr>
   <td>";
 
	
	$sqlSelSellerList="SELECT * FROM tbl_items where owner_id='$userId' and product_id='$productId' ORDER BY item_id DESC";
	$rstSelSellerList=mysql_query($sqlSelSellerList) or die(mysql_error());				
	$noSelSellerList=mysql_num_rows($rstSelSellerList);
	if($noSelSellerList==0)
	{
	       
	       $pstr.="<div style='border-top:1px solid #CCCCCC;'> </div><br>";
	       $pstr.="<p style='padding:5px;'>No items found on your list...</p><br>";
	       $pstr.="<div style='border-top:1px solid #CCCCCC;'> </div><br>";
     }
else {
			   
    $pstr.='</tr></td><tr><td>
		   
		 	<input type="hidden" name="hidDelPro" id="hidDelPro">
            <input type="hidden" name="hidDelProKey" id="hidDelProKey">
            <input type="hidden" name="hidEditSellingItemOwn" id="hidEditSellingItemOwn"> 

				   		  <table width="100%" border="0" align="center" cellspacing="0">
						  <tr class="head-tr" style="background:#F9F7F7;">
								  <td width="4%"><strong>#</strong></td>								
								  <td width="20%" align="center"><strong>Seller name </strong></td>
								  <td width="20%" align="center"><strong>Product name </strong></td>
								  <td width="20%" align="center"><strong>commission(PP)</strong></td>
								  <td width="14%" align="center"><strong>Price</strong></td>
								  <td width="14%" align="center"><strong>Shipping</strong></td>
								  <td width="8%"><strong>Action</strong></td>
						    </tr>';
						
						 $r=1;
						$pname=$productInfo['product_name'];
						 while($rowSelSellerList=mysql_fetch_array($rstSelSellerList))
					         {				
						    $sellerName=getUser($rowSelSellerList['seller_id']);	   
						    $itemId=$rowSelSellerList['item_id'];
							
							$price=$rowSelSellerList['price'];
							$commission=$rowSelSellerList['commission'];
							$productShipping=$productInfo['shipping'];
							if(!empty($productShipping) || $productShipping!='Free')
							       $productShipping="$".number_format($productShipping,2);
							else
							       $productShipping="Free";
						    $pstr.='<tr>
						   		 <td height="28">'.$r.' </td>					         
								 <td align="center">'.$sellerName.'</td>
								 <td align="center"><a href="index.php?SellProduct='.$productId.'">'.$pname.'</a></td>
								 <td align="center">$'.$commission.'</td>
								 <td align="center">$'.$price.'</td>
								 <td align="center">'.$productShipping.'</td>
								 <td><a href="javascript:void(0);" onClick="delitem('.$itemId.','.$productId.')">Delete</a></td>
							   </tr>
							<tr>
									 <td colspan="7"> <div style="border-top:1px solid #CCCCCC;"> </div> </td>
								  </tr>';
						 	$r++;
						 } 
						$pstr.='</table>';				    	
		   
		   } 								
	
	$pstr.='</form><br /></td>
</tr></table></div>';
echo $pstr;
?>



<!--<tr>
	<td><div align="center"><?php
		   //$link="editSellingProduct";
		   //echo $disp=getPagingLink($sqlSelSellerList,$itemPerPage,$link);
	 ?></div></td>
</tr>
<tr>
<td>
  <?php 
  /*if(!empty($_REQUEST['hidEditSellingItemOwn'])) {
    $sqlSelLstEdit="SELECT * FROM tbl_items where item_id=".$_REQUEST['hidEditSellingItemOwn'];
    $rstSelLstEdit=mysql_query($sqlSelLstEdit);
	$rowSelLstEdit=mysql_fetch_array($rstSelLstEdit);
	$productInfo=getProductById($rowSelLstEdit['product_id']);*/
  ?>
   <div id="divEditSellingProductOwn">
    <form name="frmEditSellingProduct" id="frmEditSellingProduct" method="post" action="">
    <input type="hidden" name="editSellingProductOwnKey" id="editSellingProductOwnKey" />
      <table width="100%" border="0">
        <tr  class='head-tr'>
          <td colspan="3"><strong>Edit product</strong></td>
        </tr>
        <tr>
          <td height="29">&nbsp;</td>
          <td><strong>Seller</strong></td>
          <td><?php //if(!empty($rowSelLstEdit['seller_id']))
			//echo $sellerName=getUser($rowSelLstEdit['seller_id']);
			?></td>
        </tr>
        <tr>
          <td height="29">&nbsp;</td>
          <td width="21%"><strong>Price</strong></td>
          <td width="77%"><input type="text" name="price" id="price" size="33" value="<?php// if(!empty($rowSelLstEdit['price']))
			//echo $rowSelLstEdit['price'];
			?>"/></td>
        </tr>
        <tr>
          <td height="31">&nbsp;</td>
          <td><strong>Comission (PP)</strong></td>
          <td><input type="text" name="commission" id="commission" size="33" value="<?php// if(!empty($rowSelLstEdit['commission']))
			//echo $rowSelLstEdit['commission'];
			?>"/></td>
        </tr>
        <tr>
          <td height="34">&nbsp;</td>
          <td>&nbsp;</td>
          <td><label>
            <input type="button" name="editSellingProduct" id="editSellingProduct" value="Edit product" onclick="funEditSellingProductOwn('frmEditSellingProduct',<?php  if(!empty($_REQUEST['hidEditSellingItemOwn'])) echo $_REQUEST['hidEditSellingItemOwn'];?>)" />
          </label></td>
        </tr>
      </table>
      </form>
    </div>
    <?php //} ?>    </td>
    </tr>
    </table>
</div>-->